package com.tianqu.tms.www.bid.controller;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsController;
import com.tianqu.tms.core.base.TxController;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.core.exception.TransactionException;
import com.tianqu.tms.core.util.StringUtil;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.entity.AucManagement;
import com.tianqu.tms.www.bid.viewhelper.BidCarSerchAllBidDetailViewHelper;
/**
 * 高级搜索-确认流拍
 * @author mufeiyu
 *
 */
public class BidCarSerchAllLiupaiResultController extends TmsController {
	private static String ID = "id";
	private Logger logger = Logger
			.getLogger(BidCarSerchAllLiupaiResultController.class);

	@Override
	public void execute(UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		TxController controller = TxController.getTxController();
		BidCarSerchAllBidDetailViewHelper viewHelper = (BidCarSerchAllBidDetailViewHelper) uc
		.getAttribute(TmsConstants.VIEWHELP);
		// 添加事务提交异常捕获
		try {
			controller.begin();
			String id = (String) uc.getAttribute(ID);
			
			AucManagement aucManagement = AucManagement.getInstance();
			aucManagement.setId(Integer.valueOf(id));
			aucManagement.setBidStatus(5);
			aucManagement.setDonePrices(0);
			aucManagement.setDoneMemberId("");
			aucManagement.updateAucManageInfo(aucManagement);
			
			viewHelper.setBidStatusName(StringUtil.getBidStatus(5));
			viewHelper.setBidStatus("5");
			viewHelper.setDonePrices("");
			viewHelper.setDoneMemberName("");
			uc.setAttribute(TmsConstants.VIEWHELP, viewHelper);
			logger.debug(this.getClass().getName() + "#execute was completed.");
			controller.commit();
		} catch (Exception e) {
			try {
				controller.rollback();
			} catch (TransactionException e1) {
				throw new TmsException(TmsException.DB_TXCRROR, e1);
			}
			// 系统异常
			if (e instanceof TmsException) {
				throw e;
			}
			throw new TmsException(TmsException.DB_TXCRROR, e);
		}

	}
}
